package ru.amse.vlassiev.view;

import java.io.*;

public class OutputStreamView implements IView {

	private String myName;
	private OutputStream myOS;
	
	public OutputStreamView(String name, OutputStream os) {
		myName = name;
		myOS = os;
	}
	
	public void update(String timestamp, long value) {
		try {
			myOS.write((myName + ": " + timestamp + " value = " + value + (char) 13 + (char) 10).getBytes());
		} catch (IOException e) {
			
		}
	}


	public void update(long date, long value) {
		try {
			long hour = (date / (60 * 60)) % 24; 
			long minute = (date / 60) % 60; 
			long second = date % 60; 
			String timestamp = hour + ":" + minute + ":" + second;
			myOS.write((myName + ": " + timestamp + " value = " + value + (char) 13 + (char) 10).getBytes());
		} catch (IOException e) {
			
		}
	}
}
